package com.json.jsonback;

import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonBackReference;

public class TreeNode {

	private String name;
	@JsonBackReference
	private TreeNode parent;
	private List<TreeNode> children;
	
	public TreeNode() {
		super();
	}
	
	public TreeNode(String name) {
		super();
		this.name = name;
	}

	public TreeNode(String name, TreeNode parent, List<TreeNode> childen) {
		super();
		this.name = name;
		this.parent = parent;
		this.children = childen;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public TreeNode getParent() {
		return parent;
	}
	public void setParent(TreeNode parent) {
		this.parent = parent;
	}
	public List<TreeNode> getChilden() {
		return children;
	}
	public void setChilden(List<TreeNode> childen) {
		this.children = childen;
	}
	public void addChild(TreeNode child){
		if(children==null)
			children=new ArrayList<TreeNode>();
		children.add(child);
	}
}
